<template>
  <el-dialog
    class="dialog_header"
    :ref="dialogRef"
    :width="width"
    :title="dialogTitle"
    :visible.sync="isShowDialog"
    :before-close="handleIconClose"
    :close-on-click-modal="false"
    @open="open"
  >
    <template v-slot:title
      ><li :class="titleIcon"></li>
      <span>{{ dialogTitle }}</span></template
    >

    <slot></slot>
    <div slot="footer" class="mt10">
      <el-button
        size="medium"
        type="primary"
        @click="handleConfirm"
        class="confirm_button"
        >确 定</el-button
      >
      <el-button size="medium" @click="handleClose" class="cancel_button"
        >取消</el-button
      >
    </div>
  </el-dialog>
</template>
<script>
import "@/assets/less/component/dialog.less";

export default {
  name: "DialogComponent",
  props: {
    width: {
      type: String,
      default: "65%",
    },
    dialogTitle: {
      type: String,
      default: "",
    },
    titleIcon: {
      type: String,
      default: "",
    },
    isShowDialog: {
      type: Boolean,
      default: false,
    },
    dialogRef: {
      type: String,
      default: "dialogRef",
    },
  },
  methods: {
    handleIconClose() {
      this.$emit("update:isShowDialog", false);
      this.$emit("handleClose");
    },
    handleClose() {
      this.handleIconClose();
    },
    handleConfirm() {
      this.$emit("handleConfirm");
    },
    open() {
      this.$emit("open");
    },
  },
};
</script>
<style lang="less" scoped >
.confirm_button {
  background-color: #08437f;
  border-color: #08437f;
}
.cancel_button {
  color: #08437f;
  border-color: #08437f;
}
</style>
